const FileManagerPlugin = require('filemanager-webpack-plugin');
const dirName = 'h5.zip';
const envPath = './dist/build/h5';
const configureWebpack = {
  plugins: [ ]
}
if (  process.env.VUE_APP_PLATFORM==='h5' && process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test') {
  configureWebpack.plugins.push(
    new FileManagerPlugin({
      events: {
        onStart: {
          delete: [
            `./${dirName}`,
          ],
        },
        onEnd: {
          mkdir: [`${envPath}`], //避免没有此文件  
          delete: [
            `./${dirName}`,
          ],
          archive: [{
            source: `${envPath}`,
            destination: `./${dirName}`
          },]
        },
      }
    })
  )
}

module.exports = {
  configureWebpack
};
